package com.cqie.tes.controller;

import com.cqie.tes.comm.R;
import com.cqie.tes.service.RoleMenuService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@Api("角色菜单管理")
@RestController
@RequestMapping("rolemenu")
public class RoleMenuController {

    @Autowired
    private RoleMenuService roleMenuService;
    // 基本方法

    //
    @GetMapping("/getRolePermissionByRoleId/{id}")
    public R getRolePermissionByRoleId(@PathVariable("id") Integer roleId) {
        return roleMenuService.getRolePermissionByRoleId(roleId);
    }

    @PostMapping("/setRolePermission/{id}")
    public R setRolePermission(
            @PathVariable("id") Long id,
            @RequestBody Map<String, String> funcMapList) {
        System.out.println(id);
        funcMapList.keySet().forEach(key->{
            System.out.println("key:"+key+ " value:"+funcMapList.get(key));
        });
        return roleMenuService.setRolePermission(id,funcMapList);
    }

}
